package etcdclient

import (
	"flag"
	"strings"
	"sync"
)

type envConfig struct {
	Username  string
	Password  string
	Endpoints []string
	once      sync.Once
}

var envConf envConfig

func parseFlags() *envConfig {
	envConf.once.Do(func() {
		endpoints := flag.String("endpoints", "localhost:2379", "Comma-separated list of etcd endpoints")
		userName := flag.String("username", "", "etcd username")
		password := flag.String("password", "", "etcd password")
		flag.Parse()
		envConf.Endpoints = strings.Split(*endpoints, ",")
		envConf.Username = *userName
		envConf.Password = *password
	})
	return &envConf
}
